package com.yinhe.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yinhe.common.annotation.Log;
import com.yinhe.common.core.controller.BaseController;
import com.yinhe.common.core.domain.AjaxResult;
import com.yinhe.common.enums.BusinessType;
import com.yinhe.system.domain.YhFileVerify;
import com.yinhe.system.service.IYhFileVerifyService;
import com.yinhe.common.utils.poi.ExcelUtil;
import com.yinhe.common.core.page.TableDataInfo;

/**
 * 文件审核Controller
 * 
 * @author yinhe
 * @date 2022-08-09
 */
@RestController
@RequestMapping("/system/verify")
public class YhFileVerifyController extends BaseController
{
    @Autowired
    private IYhFileVerifyService yhFileVerifyService;

    /**
     * 查询文件审核列表
     */
    @PreAuthorize("@ss.hasPermi('system:verify:list')")
    @GetMapping("/list")
    public TableDataInfo list(YhFileVerify yhFileVerify)
    {
        startPage();
        List<YhFileVerify> list = yhFileVerifyService.selectYhFileVerifyList(yhFileVerify);
        return getDataTable(list);
    }

    /**
     * 导出文件审核列表
     */
    @PreAuthorize("@ss.hasPermi('system:verify:export')")
    @Log(title = "文件审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YhFileVerify yhFileVerify)
    {
        List<YhFileVerify> list = yhFileVerifyService.selectYhFileVerifyList(yhFileVerify);
        ExcelUtil<YhFileVerify> util = new ExcelUtil<YhFileVerify>(YhFileVerify.class);
        util.exportExcel(response, list, "文件审核数据");
    }

    /**
     * 获取文件审核详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:verify:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(yhFileVerifyService.selectYhFileVerifyById(id));
    }

    /**
     * 新增文件审核
     */
    @PreAuthorize("@ss.hasPermi('system:verify:add')")
    @Log(title = "文件审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YhFileVerify yhFileVerify)
    {
        return toAjax(yhFileVerifyService.insertYhFileVerify(yhFileVerify));
    }

    /**
     * 修改文件审核
     */
    @PreAuthorize("@ss.hasPermi('system:verify:edit')")
    @Log(title = "文件审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YhFileVerify yhFileVerify)
    {
        return toAjax(yhFileVerifyService.updateYhFileVerify(yhFileVerify));
    }

    /**
     * 删除文件审核
     */
    @PreAuthorize("@ss.hasPermi('system:verify:remove')")
    @Log(title = "文件审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yhFileVerifyService.deleteYhFileVerifyByIds(ids));
    }
}
